package com.yfp.client.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfp.client.domain.Combo;
import com.yfp.client.domain.ImgResource;
import com.yfp.client.mapper.ComboMapper;
import com.yfp.client.service.ComboService;
import com.yfp.client.service.ImgResourceService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author admin
 * @description 针对表【combo(套餐表)】的数据库操作Service实现
 * @createDate 2024-06-05 14:19:43
 */
@Service
public class ComboServiceImpl extends ServiceImpl<ComboMapper, Combo> implements ComboService {

    @Resource
    private ComboMapper comboMapper;
    @Resource
    private ImgResourceService imgResourceService;

    /**
     * 根据套餐id查询套餐信息
     *
     * @param packageIds
     * @return
     */
    @Override
    public List<Combo> listByPackageIds(List<String> packageIds) {
        if (CollUtil.isEmpty(packageIds)){
            return List.of();
        }
        List<Combo> combos = comboMapper.selectBatchIds(packageIds);
        return combos;
    }

    @Override
    public String getComboImageUrl(String thumb) {
        ImgResource imgResource = imgResourceService.getById(thumb);
        return imgResource.getUrl();
    }
}




